﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;
using System.Data.OleDb;
namespace GUI
{
    public partial class FormBCDoanhThu : Window
    {
        public FormBCDoanhThu()
        {
            InitializeComponent();
            hoiThoat = false;
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
        private void LoadData()
        {
            DateTime st = dtbBatDau.Value;
            DateTime en = dtbKetThuc.Value;
            OleDbDataAdapter dtap=BUS.DoanhThuBUS.BCDoanhThu(st, en);
            DataSet ds = new DataSet();
            dtap.Fill(ds);
            this.GridViewdoanhthu.DataSource = ds.Tables[0];            
            GridViewdoanhthu.Columns[0].HeaderText = "Mã hóa đơn";
            GridViewdoanhthu.Columns[1].HeaderText = "Ngày HĐ";
            GridViewdoanhthu.Columns[1].DefaultCellStyle.Format="dd/MM/yyyy";
            GridViewdoanhthu.Columns[2].Visible = false;
            GridViewdoanhthu.Columns[3].HeaderText = "Mã khách hàng";
            GridViewdoanhthu.Columns[4].HeaderText = "Tên khách hàng";
            GridViewdoanhthu.Columns[5].Visible = false;
            GridViewdoanhthu.Columns[6].HeaderText = "Thành tiền";
            GridViewdoanhthu.Columns[7].Visible = false;
            GridViewdoanhthu.Columns[8].Visible = false;
            GridViewdoanhthu.Columns[9].HeaderText = "Ghi chú";
            GridViewdoanhthu.Columns[10].Visible = false;
          
            BUS.DoanhThuBUS dt=new DoanhThuBUS();
            txtThanhTien.Text = dt.TongTienHDTheoNgay(st, en).ToString();
        }

        private void FormBCDoanhThu_Load(object sender, EventArgs e)
        {
            LoadData();

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnXem_Click(object sender, EventArgs e)
        {
            LoadData();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            XuatExcel(GridViewdoanhthu, "BaoCaoDoanhThu");
        }
    }
}
